/**
 * @param {number[]} nums
 * @return {number[]}
 * 快排
 */
 var sortArray = function (nums) {
    if (!nums) return
    quickSort(nums, 0, nums.length - 1)
    return nums
  };
  
  const quickSort = (arr, low, high) => {
    if (low >= high) return
    const index = patition(arr, low, high)
    quickSort(arr, low, index)
    quickSort(arr, index + 1, high)
  }
  
  const patition = (arr, left, right) => {
    let pivot = arr[left]
    while (left < right) {
      while (left < right && arr[right] >= pivot) {
        right--
      }
      arr[left] = arr[right]
      while (left < right && arr[left] <= pivot) {
        left++
      }
      arr[right] = arr[left]
    }
    arr[left] = pivot
    return left
  }

  